package com.fowo.api.sys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fowo.api.common.model.SimpleItem;
import com.fowo.api.sys.entity.SysRole;
import com.fowo.api.sys.entity.SysRolePermission;
import com.fowo.api.sys.entity.SysRolePermissionDepartments;
import com.fowo.api.sys.model.SysRoleItemVo;
import com.fowo.api.sys.model.SysRoleSearchParamPo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface SysRoleMapper extends BaseMapper<SysRole> {
    List<SimpleItem> selectSimplesByUserId(@Param("userId") Long userId);

    List<SysRoleItemVo> search(@Param("search") SysRoleSearchParamPo search);

    List<SysRoleItemVo> searchSysRole(@Param("search") SysRoleSearchParamPo search);

    Page<SysRoleItemVo> searchPage(Page page, @Param("search") SysRoleSearchParamPo search);

    SysRolePermission selectRolePermissionByRoleId(@Param("roleId") Long roleId);

    List<SysRolePermissionDepartments> selectRolePermissionDepartmentsByRoleId(@Param("rolePermissionId") Long rolePermissionId);

    /**
     * 获取指定的角色名称是否存在
     * @param roleName 角色名称
     * @param excludeId 排除编号（可空）
     */
    Boolean selectExistsRoleName(@Param("roleName") String roleName, @Param("excludeId") Long excludeId);
}
